#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
=================================================
# @File    : setting
# @IDE     : PyCharm
# @Author  : liuxiangui
# @Date    : 2023/10/28 21:55
# @Describe:
==================================================
'''

import os
import socket
from typing import Text, Dict, List, Union

def get_host_ip():
    """
    查询本机ip地址
    :return:
    """
    _s = None
    try:
        _s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        _s.connect(('8.8.8.8', 80))
        host = _s.getsockname()[0]
    finally:
        _s.close()

    return host


def root_path():
    """ 获取 根路径 """
    path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    return path

def get_all_files(filePath: Text, fileType: Text) -> List:
    """
    获取路径下，指定类型文件
    :param filePath: 目录路径
    :param fileType: 过滤文件类型
    :return: List
    """
    filename = []
    # 获取所有文件下的子文件名称
    for root, dirs, files in os.walk(filePath):
        for _filePath in files:
            path = os.path.join(root, _filePath)
            if fileType in path:
                filename.append(path)
            else:
                filename.append(path)
    return filename

